package 字符串;

/**
 * @Author: biubiu0002
 * @Date: 2021-09-15 11:22
 **/
public class 比较版本号 {
    public static void main(String[] args) {

    }

     public int compareVersion(String v1, String v2) {
         String[] ss1 = v1.split("\\."), ss2 = v2.split("\\.");
         int n = ss1.length, m = ss2.length;
         int i = 0, j = 0;
         while (i < n || j < m) {
             int a = 0, b = 0;
             if (i < n) a = Integer.parseInt(ss1[i++]);
             if (j < m) b = Integer.parseInt(ss2[j++]);
             if (a != b) return a > b ? 1 : -1;
         }
         return 0;
     }
}
